package sdk

import (
	"encoding/xml"
	"fmt"
)

// 模拟支付宝支付sdk
// AlipayClient 支付宝原生客户端
type AlipayClient struct {
	AppID     string
	AppSecret string
}

// AlipayRequest 支付宝原生请求
type AlipayRequest struct {
	XMLName     xml.Name `xml:"alipay"`
	Service     string   `xml:"service"`
	Partner     string   `xml:"partner"`
	OutTradeNo  string   `xml:"out_trade_no"`
	TotalFee    float64  `xml:"total_fee"`
	Subject     string   `xml:"subject"`
	Body        string   `xml:"body"`
	PaymentType int      `xml:"payment_type"`
}

// AlipayResponse 支付宝原生响应
type AlipayResponse struct {
	XMLName    xml.Name `xml:"alipay"`
	IsSuccess  string   `xml:"is_success"`
	TradeNo    string   `xml:"trade_no"`
	ResultCode string   `xml:"result_code"`
	Error      string   `xml:"error"`
}

// ProcessAlipayPayment 处理支付宝支付
func (c *AlipayClient) ProcessAlipayPayment(req AlipayRequest) (*AlipayResponse, error) {
	// 模拟实际调用支付宝接口
	fmt.Printf("调用支付宝接口: %+v\n", req)

	return &AlipayResponse{
		IsSuccess:  "T",
		TradeNo:    "ALI" + req.OutTradeNo,
		ResultCode: "10000",
		Error:      "",
	}, nil
}
